{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Detail\n",
    "\n",
    "It is possible to fine tune the level of details with which curved paths are rendered."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"231.84pt\" version=\"1.1\" viewBox=\"0 0 349.2 231.84\" width=\"349.2pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2020-08-12T15:59:16.696699</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.3.0, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 231.84 \n",
       "L 349.2 231.84 \n",
       "L 349.2 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 324.245991 11.018957 \n",
       "L 328.064948 11.018957 \n",
       "L 328.064948 224.64 \n",
       "L 24.954009 224.64 \n",
       "L 24.954009 220.821043 \n",
       "L 324.245991 220.821043 \n",
       "z\n",
       "\" style=\"opacity:0.3;\"/>\n",
       "   </g>\n",
       "   <g id=\"LineCollection_1\">\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 78.870424 114.010521 \n",
       "L 78.754445 112.721889 \n",
       "L 78.410235 111.474675 \n",
       "L 77.848859 110.308965 \n",
       "L 77.088359 109.262226 \n",
       "L 76.153177 108.368101 \n",
       "L 75.073372 107.655328 \n",
       "L 73.88365 107.146816 \n",
       "L 72.622248 106.858909 \n",
       "L 71.32971 106.800861 \n",
       "L 70.047579 106.974538 \n",
       "L 68.817064 107.374356 \n",
       "L 67.677713 107.987467 \n",
       "L 66.666148 108.794164 \n",
       "L 65.81488 109.768518 \n",
       "L 65.15127 110.879214 \n",
       "L 64.696647 112.090553 \n",
       "L 64.465623 113.363601 \n",
       "L 64.465623 114.657442 \n",
       "L 64.696647 115.93049 \n",
       "L 65.15127 117.141829 \n",
       "L 65.81488 118.252525 \n",
       "L 66.666148 119.226879 \n",
       "L 67.677713 120.033576 \n",
       "L 68.817064 120.646686 \n",
       "L 70.047579 121.046505 \n",
       "L 71.32971 121.220182 \n",
       "L 72.622248 121.162134 \n",
       "L 73.88365 120.874227 \n",
       "L 75.073372 120.365715 \n",
       "L 76.153177 119.652942 \n",
       "L 77.088359 118.758817 \n",
       "L 77.848859 117.712078 \n",
       "L 78.410235 116.546368 \n",
       "L 78.754445 115.299153 \n",
       "L 78.870424 114.010521 \n",
       "L 78.870424 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 86.087351 114.010521 \n",
       "L 85.983776 112.284476 \n",
       "L 85.674539 110.583202 \n",
       "L 85.164077 108.931116 \n",
       "L 84.459717 107.351927 \n",
       "L 83.571566 105.8683 \n",
       "L 82.512372 104.501527 \n",
       "L 81.297335 103.271223 \n",
       "L 79.943894 102.195046 \n",
       "L 78.471472 101.28844 \n",
       "L 76.901201 100.564416 \n",
       "L 75.255617 100.033366 \n",
       "L 73.558337 99.70291 \n",
       "L 71.83372 99.577792 \n",
       "L 70.106515 99.659807 \n",
       "L 68.401513 99.947778 \n",
       "L 66.743182 100.437572 \n",
       "L 65.155321 101.12216 \n",
       "L 63.66072 101.991716 \n",
       "L 62.280829 103.033762 \n",
       "L 61.03545 104.233342 \n",
       "L 59.942457 105.573241 \n",
       "L 59.017537 107.034228 \n",
       "L 58.273963 108.595336 \n",
       "L 57.722407 110.234161 \n",
       "L 57.370785 111.927182 \n",
       "L 57.224143 113.650103 \n",
       "L 57.284585 115.378197 \n",
       "L 57.551245 117.086662 \n",
       "L 58.020294 118.75098 \n",
       "L 58.685003 120.347264 \n",
       "L 59.53583 121.852606 \n",
       "L 60.560565 123.245401 \n",
       "L 61.744501 124.505661 \n",
       "L 63.070648 125.615299 \n",
       "L 64.519973 126.558389 \n",
       "L 66.071675 127.321397 \n",
       "L 67.703485 127.893373 \n",
       "L 69.391984 128.266107 \n",
       "L 71.11294 128.43425 \n",
       "L 72.841654 128.39539 \n",
       "L 74.553315 128.150083 \n",
       "L 76.22336 127.701851 \n",
       "L 77.827819 127.057126 \n",
       "L 79.343667 126.225161 \n",
       "L 80.749149 125.217897 \n",
       "L 82.024093 124.049788 \n",
       "L 83.150203 122.7376 \n",
       "L 84.111316 121.300164 \n",
       "L 84.893639 119.75811 \n",
       "L 85.485945 118.133568 \n",
       "L 85.879733 116.449855 \n",
       "L 86.069351 114.731132 \n",
       "L 86.087351 114.010521 \n",
       "L 86.087351 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 100.521205 114.010521 \n",
       "L 100.404437 111.416681 \n",
       "L 100.055078 108.843824 \n",
       "L 99.475954 106.312765 \n",
       "L 98.67175 103.84398 \n",
       "L 97.648972 101.457441 \n",
       "L 96.415895 99.172454 \n",
       "L 94.982492 97.007506 \n",
       "L 93.360362 94.980109 \n",
       "L 91.562626 93.106666 \n",
       "L 89.603828 91.402332 \n",
       "L 87.499814 89.880896 \n",
       "L 85.267605 88.554665 \n",
       "L 82.92526 87.434368 \n",
       "L 80.491728 86.529069 \n",
       "L 77.986697 85.84609 \n",
       "L 75.43043 85.390959 \n",
       "L 72.843608 85.167355 \n",
       "L 70.247159 85.177089 \n",
       "L 67.662087 85.420082 \n",
       "L 65.109304 85.894367 \n",
       "L 62.609464 86.596108 \n",
       "L 60.182788 87.519628 \n",
       "L 57.848909 88.657455 \n",
       "L 55.626707 90.000386 \n",
       "L 53.534159 91.537555 \n",
       "L 51.588195 93.256528 \n",
       "L 49.804556 95.143397 \n",
       "L 48.197672 97.182899 \n",
       "L 46.780542 99.358534 \n",
       "L 45.564632 101.652701 \n",
       "L 44.559776 104.046842 \n",
       "L 43.774105 106.521588 \n",
       "L 43.213975 109.056918 \n",
       "L 42.883916 111.632321 \n",
       "L 42.7866 114.226965 \n",
       "L 42.922812 116.819857 \n",
       "L 43.291452 119.390022 \n",
       "L 43.889537 121.916668 \n",
       "L 44.712229 124.379354 \n",
       "L 45.752872 126.758157 \n",
       "L 47.003047 129.033834 \n",
       "L 48.452641 131.187975 \n",
       "L 50.089927 133.203152 \n",
       "L 51.901659 135.063063 \n",
       "L 53.873181 136.752662 \n",
       "L 55.988543 138.258281 \n",
       "L 58.230633 139.567738 \n",
       "L 60.581312 140.670441 \n",
       "L 63.021563 141.557469 \n",
       "L 65.531645 142.221646 \n",
       "L 68.091252 142.657598 \n",
       "L 70.679678 142.8618 \n",
       "L 73.275981 142.832599 \n",
       "L 75.859159 142.570231 \n",
       "L 78.408313 142.076819 \n",
       "L 80.902822 141.356354 \n",
       "L 83.322505 140.414666 \n",
       "L 85.647788 139.259371 \n",
       "L 87.859858 137.899817 \n",
       "L 89.940822 136.347001 \n",
       "L 91.873843 134.613487 \n",
       "L 93.643284 132.713297 \n",
       "L 95.234832 130.661805 \n",
       "L 96.635609 128.475606 \n",
       "L 97.834284 126.172386 \n",
       "L 98.821161 123.770778 \n",
       "L 99.588255 121.290212 \n",
       "L 100.12936 118.750753 \n",
       "L 100.4401 116.172947 \n",
       "L 100.521205 114.010521 \n",
       "L 100.521205 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 179.907403 114.010521 \n",
       "L 177.190157 108.368101 \n",
       "L 171.084559 106.974538 \n",
       "L 166.18825 110.879214 \n",
       "L 166.18825 117.141829 \n",
       "L 171.084559 121.046505 \n",
       "L 177.190157 119.652942 \n",
       "L 179.907403 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 187.124331 114.010521 \n",
       "L 185.471019 107.302775 \n",
       "L 180.88984 102.131692 \n",
       "L 174.430285 99.681906 \n",
       "L 167.572161 100.514633 \n",
       "L 161.886581 104.439106 \n",
       "L 158.676044 110.556274 \n",
       "L 158.676044 117.464769 \n",
       "L 161.886581 123.581937 \n",
       "L 167.572161 127.50641 \n",
       "L 174.430285 128.339137 \n",
       "L 180.88984 125.889351 \n",
       "L 185.471019 120.718268 \n",
       "L 187.124331 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 201.558185 114.010521 \n",
       "L 200.719342 107.102027 \n",
       "L 198.251563 100.595028 \n",
       "L 194.298266 94.86769 \n",
       "L 189.089204 90.252863 \n",
       "L 182.927107 87.018745 \n",
       "L 176.170094 85.353291 \n",
       "L 169.210859 85.353291 \n",
       "L 162.453846 87.018745 \n",
       "L 156.291749 90.252863 \n",
       "L 151.082686 94.86769 \n",
       "L 147.12939 100.595028 \n",
       "L 144.661611 107.102027 \n",
       "L 143.822768 114.010521 \n",
       "L 144.661611 120.919016 \n",
       "L 147.12939 127.426014 \n",
       "L 151.082686 133.153353 \n",
       "L 156.291749 137.76818 \n",
       "L 162.453846 141.002298 \n",
       "L 169.210859 142.667752 \n",
       "L 176.170094 142.667752 \n",
       "L 182.927107 141.002298 \n",
       "L 189.089204 137.76818 \n",
       "L 194.298266 133.153353 \n",
       "L 198.251563 127.426014 \n",
       "L 200.719342 120.919016 \n",
       "L 201.558185 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 280.944383 114.010521 \n",
       "L 270.118992 107.760479 \n",
       "L 270.118992 120.260564 \n",
       "L 280.944383 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 288.16131 114.010521 \n",
       "L 273.727456 99.576667 \n",
       "L 259.293602 114.010521 \n",
       "L 273.727456 128.444376 \n",
       "L 288.16131 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 302.595164 114.010521 \n",
       "L 291.726178 91.440838 \n",
       "L 267.303787 85.866587 \n",
       "L 247.718549 101.485292 \n",
       "L 247.718549 126.535751 \n",
       "L 267.303787 142.154456 \n",
       "L 291.726178 136.580205 \n",
       "L 302.595164 114.010521 \n",
       "\" style=\"fill:none;stroke:#0000ff;stroke-opacity:0.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_1\">\n",
       "    <path clip-path=\"url(#p8ff3a62670)\" d=\"M 21.135052 7.2 \n",
       "L 324.245991 7.2 \n",
       "L 324.245991 220.821043 \n",
       "L 21.135052 220.821043 \n",
       "L 21.135052 7.2 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-width:0.25;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p8ff3a62670\">\n",
       "   <rect height=\"217.44\" width=\"334.8\" x=\"7.2\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "import vsketch\n",
    "\n",
    "vsk = vsketch.Vsketch()\n",
    "vsk.size(\"a5\", landscape=True)\n",
    "vsk.scale(\"1cm\")\n",
    "\n",
    "# high level of detail\n",
    "vsk.detail(\"0.1mm\")\n",
    "vsk.circle(0, 0, 1)\n",
    "vsk.circle(0, 0, 2)\n",
    "with vsk.pushMatrix():\n",
    "    vsk.scale(4)\n",
    "    vsk.circle(0, 0, 1)\n",
    "\n",
    "# rough level of detail\n",
    "vsk.translate(7, 0)\n",
    "vsk.detail(\"5mm\")\n",
    "vsk.circle(0, 0, 1)\n",
    "vsk.circle(0, 0, 2)\n",
    "with vsk.pushMatrix():\n",
    "    vsk.scale(4)\n",
    "    vsk.circle(0, 0, 1)\n",
    "\n",
    "# hardly usable level of detail\n",
    "vsk.translate(7, 0)\n",
    "vsk.detail(\"2cm\")\n",
    "vsk.circle(0, 0, 1)\n",
    "vsk.circle(0, 0, 2)\n",
    "with vsk.pushMatrix():\n",
    "    vsk.scale(4)\n",
    "    vsk.circle(0, 0, 1)\n",
    "\n",
    "vsk.display()\n",
    "vsk.save(\"detail.svg\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
